package com.easy.west.westclient.api.login.api;

import android.content.Context;

import com.easy.west.westclient.api.base.callback.BaseCallBack;
import com.easy.west.westclient.api.base.impl.BaseImpl;
import com.easy.west.westclient.api.login.bean.User;
import com.easy.west.westclient.api.login.event.FindUserEvent;
import com.easy.west.westclient.api.login.event.LoginEvent;
import com.easy.west.westclient.util.UUIDGenerator;

/**
 * 登录
 * Created by xiatao on 2018/7/31.
 */

public class LoginImpl extends BaseImpl<LoginService> implements LoginApi {

    public LoginImpl(Context context)
    {
        super(context);
    }

    /**
     * 登录
     * @param username
     * @param pwd
     * @return
     */
    @Override
    public String login(String username, String pwd) {
        String uuid = UUIDGenerator.getUUID();
        service.login(username,pwd).enqueue(new BaseCallBack<User>(new LoginEvent(uuid)));
        return uuid;
    }

    @Override
    public String finduser(int uid) {
        String uuid = UUIDGenerator.getUUID();
        service.finduser(uid).enqueue(new BaseCallBack<User>(new FindUserEvent(uuid)));
        return uuid;
    }
}
